package day15;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class testlist {
    public static void main(String[] args) {
        List<String> list=new ArrayList();
        list.add("aa");
        list.add("bb");
        list.add("cc");
        list.add("dd");
        System.out.println(list);
        System.out.println("*************迭代方法一**********");
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        System.out.println("*************迭代方法二**********");
        for (String e:list){
            System.out.println(e);
        }
        System.out.println("*************迭代方法三**********");
        Iterator<String> it = list.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("*************迭代方法四**********");
        ListIterator<String> it2 = list.listIterator();
        while (it2.hasNext()){
            System.out.println(it2.next());
        }
    }
}
